/** 
* Project Name:lg_service 
* File Name:SecurityNativeChannelService.java 
* Package Name:com.wl.api.service.business.impl 
* Date:2018年5月7日下午10:34:38 
* Copyright (c) 2018, lanls All Rights Reserved. 
* 
*/
package com.wl.api.service.system.impl;

import static com.wl.api.common.utils.PageInfo.transformPage;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.wl.api.common.utils.PageInfo;
import com.wl.api.dto.system.SecurityNativeChannelNetworkDTO;
import com.wl.api.mapper.system.SecurityNativeChannelNetworkMapper;
import com.wl.api.model.system.SecurityNativeChannelNetwork;
import com.wl.api.service.system.ISecurityNativeChannelNetworkService;

/**
 * ClassName: SecurityNativeChannelService <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2018年5月7日 下午10:34:38 <br/>
 * 
 * @author lanls
 * @version
 * @since JDK 1.6
 */
@Service
public class SecurityNativeChannelNetworkService
		extends ServiceImpl<SecurityNativeChannelNetworkMapper, SecurityNativeChannelNetwork>
		implements ISecurityNativeChannelNetworkService {

	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * 
	 * @see com.wl.api.service.system.ISecurityNativeChannelNetworkService#selectByDynamic(com.wl.api.dto.system.SecurityNativeChannelNetworkDTO)
	 */
	@Override
	public PageInfo<SecurityNativeChannelNetworkDTO> selectByDynamicParameter(SecurityNativeChannelNetworkDTO param) {

		/**
		 * 动态参数查询逻辑在此处使用Wrapper添加
		 */
		Wrapper<SecurityNativeChannelNetwork> wrapper = new EntityWrapper<SecurityNativeChannelNetwork>()
				.where(" 1=1 ");

		if (null != param.getId()) {
			wrapper.andNewSimple("id", param.getId());
		}

		if (null != param.getAreaId()) {
			wrapper.andNewSimple("area_id", param.getAreaId());
		}

		if (null != param.getIsDisabled()) {
			wrapper.andNewSimple("is_disabled", param.getIsDisabled());
		}

		if (StringUtils.isNotBlank(param.getAddress())) {
			wrapper.like("address", param.getAddress());
		}

		if (null != param.getStatus()) {
			wrapper.andNewSimple("status", param.getStatus());
		}

		if (null != param.getChannelId()) {
			wrapper.andNewSimple("channel_id", param.getChannelId());
		}

		if (StringUtils.isNotBlank(param.getName())) {
			wrapper.like("name", param.getName());
		}

		Page<SecurityNativeChannelNetwork> page = selectPage(
				new Page<>(param.getPage(), param.getPageSize(), "id", true), wrapper);
		PageInfo<SecurityNativeChannelNetworkDTO> pageInfo = transformPage(SecurityNativeChannelNetworkDTO.class, page);

		return pageInfo;
	}
}
